package com.itheima.reggie.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.reggie.common.R;
import com.itheima.reggie.pojo.Category;
import com.itheima.reggie.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/category")
public class CategoryController {
    @Autowired
    private CategoryService categoryService;
    @PostMapping
    public R add(@RequestBody Category category){
        R r = categoryService.add(category);
        return r;
    }
    @GetMapping("/page")
    public R findPage(Integer page, Integer pageSize){
        R r = categoryService.findPage(page,pageSize);
        return r;
    }
    @DeleteMapping
    public R removeById(Long id){
       R r = categoryService.removeById(id);
        return r;
    }
    @GetMapping("/list")
    public R findList(Integer type){
        R r = categoryService.findList(type);
        return r;
    }
}
